/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.delivery.transfers;

import com.mycompany.delivery.dto.ContactDTO;
import com.mycompany.delivery.entities.Contact;

/**
 * class transform DTO <-> entity
 * @author mhunek
 */
public class ContactT {
    public static Contact dTOtoEntity(ContactDTO contactDTO) {
        if(contactDTO== null) {
            return null;
        }
        
        Contact contact = new Contact();
        contact.id = contactDTO.getId();
        contact.setCity(contactDTO.getCity());
        contact.setEmail(contactDTO.getEmail());
        contact.setName(contactDTO.getName());
        contact.setPhone(contactDTO.getPhone());
        contact.setStreet(contactDTO.getStreet());
        contact.setSurname(contactDTO.getSurname());
        contact.setZip(contactDTO.getZip());
        
        return contact;
        
        
    }
    
    public static ContactDTO entityToDTO(Contact contact) {
         if(contact== null) {
            return null;
        }
        
        ContactDTO contactDTO = new ContactDTO();
        contactDTO.setId(contact.id);
        contactDTO.setCity(contact.getCity());
        contactDTO.setEmail(contact.getEmail());
        contactDTO.setName(contact.getName());
        contactDTO.setPhone(contact.getPhone());
        contactDTO.setStreet(contact.getStreet());
        contactDTO.setSurname(contact.getSurname());
        contactDTO.setZip(contact.getZip());
        
        return contactDTO;
    }
    
}
